﻿namespace Chain.BLL
{
    using Chain.IDAL;
    using Chain.Model;
    using System;
    using System.Collections;
    using System.Collections.Generic;
    using System.Data;

    public class GoodsLogDetail
    {
        private readonly Chain.IDAL.GoodsLogDetail dal = new Chain.IDAL.GoodsLogDetail();

        public int Add(Chain.Model.GoodsLogDetail model)
        {
            return this.dal.Add(model);
        }

        public List<Chain.Model.GoodsLogDetail> DataTableToList(DataTable dt)
        {
            List<Chain.Model.GoodsLogDetail> list = new List<Chain.Model.GoodsLogDetail>();
            int count = dt.Rows.Count;
            if (count > 0)
            {
                for (int i = 0; i < count; i++)
                {
                    Chain.Model.GoodsLogDetail item = new Chain.Model.GoodsLogDetail();
                    if ((dt.Rows[i]["GoodsLogDetailID"] != null) && (dt.Rows[i]["GoodsLogDetailID"].ToString() != ""))
                    {
                        item.GoodsLogDetailID = int.Parse(dt.Rows[i]["GoodsLogDetailID"].ToString());
                    }
                    if ((dt.Rows[i]["GoodsLogID"] != null) && (dt.Rows[i]["GoodsLogID"].ToString() != ""))
                    {
                        item.GoodsLogID = int.Parse(dt.Rows[i]["GoodsLogID"].ToString());
                    }
                    if ((dt.Rows[i]["GoodsID"] != null) && (dt.Rows[i]["GoodsID"].ToString() != ""))
                    {
                        item.GoodsID = int.Parse(dt.Rows[i]["GoodsID"].ToString());
                    }
                    if ((dt.Rows[i]["GoodsInPrice"] != null) && (dt.Rows[i]["GoodsInPrice"].ToString() != ""))
                    {
                        item.GoodsInPrice = decimal.Parse(dt.Rows[i]["GoodsInPrice"].ToString());
                    }
                    if ((dt.Rows[i]["GoodsOutPrice"] != null) && (dt.Rows[i]["GoodsOutPrice"].ToString() != ""))
                    {
                        item.GoodsOutPrice = decimal.Parse(dt.Rows[i]["GoodsOutPrice"].ToString());
                    }
                    if ((dt.Rows[i]["GoodsNumber"] != null) && (dt.Rows[i]["GoodsNumber"].ToString() != ""))
                    {
                        item.GoodsNumber = decimal.Parse(dt.Rows[i]["GoodsNumber"].ToString());
                    }
                    list.Add(item);
                }
            }
            return list;
        }

        public bool Delete(int GoodsLogDetailID)
        {
            return this.dal.Delete(GoodsLogDetailID);
        }

        public bool DeleteDetail(int goodsLogID)
        {
            return this.dal.DeleteDetail(goodsLogID);
        }

        public bool DeleteList(string GoodsLogDetailIDlist)
        {
            return this.dal.DeleteList(GoodsLogDetailIDlist);
        }

        public bool ExeclDataInput(ArrayList sqlArray)
        {
            return this.dal.ExeclDataInput(sqlArray);
        }

        public bool Exists(int GoodsLogDetailID)
        {
            return this.dal.Exists(GoodsLogDetailID);
        }

        public DataSet GetAllList()
        {
            return this.GetList("");
        }

        public DataSet getGoodsLogDetail(string strWhere)
        {
            return this.dal.getGoodsLogDetail(strWhere);
        }

        public DataSet GetInsufficientCount(string strWhere)
        {
            return this.dal.GetInsufficientCount(strWhere);
        }

        public DataSet GetList(string strWhere)
        {
            return this.dal.GetList(strWhere);
        }

        public DataSet GetList(int Top, string strWhere, string filedOrder)
        {
            return this.dal.GetList(Top, strWhere, filedOrder);
        }

        public DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex)
        {
            return this.dal.GetListByPage(strWhere, orderby, startIndex, endIndex);
        }

        public DataSet GetListSP(string strWhere)
        {
            return this.dal.GetListSP(strWhere);
        }

        public Chain.Model.GoodsLogDetail GetModel(int GoodsLogDetailID)
        {
            return this.dal.GetModel(GoodsLogDetailID);
        }

        public List<Chain.Model.GoodsLogDetail> GetModelList(string strWhere)
        {
            DataSet list = this.dal.GetList(strWhere);
            return this.DataTableToList(list.Tables[0]);
        }

        public int GetRecordCount(string strWhere)
        {
            return this.dal.GetRecordCount(strWhere);
        }

        public bool Update(Chain.Model.GoodsLogDetail model)
        {
            return this.dal.Update(model);
        }
    }
}

